package model

import "gitee.com/Frank098/devops-app-mgt/utils"

// public
type Result struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

// pods
type PodsNp struct {
	Namespace         string             `json:"namespace"`
	PodConventionInfo *PodConventionInfo `json:"pod_convention_info"`
}

type PodConventionInfo struct {
	Status       string `json:"status"`
	Name         string `json:"name"`
	Image        string `json:"image"`
	Age          int    `json:"age"`
	RestartCount int    `json:"restart_count"`
	PodIp        string `json:"pod_ip"`
	NodeName     string `json:"node_name"`
	Cpu          string `json:"cpu"`
	Memory       string `json:"memory"`
}

type PodYamlResponse struct {
	PodYaml string `json:"pod_yaml"`
}

// deployment
type DeploysNp struct {
	Namespace            string                `json:"namespace"`
	DeployConventionInfo *DeployConventionInfo `json:"deploy_convention_info"`
}

type DeployConventionInfo struct {
	Status            string `json:"status"`
	Name              string `json:"name"`
	Image             string `json:"image"`
	Replicas          int32  `json:"replicas"`
	UpdatedReplicas   int32  `json:"updated_replicas"`
	ReadyReplicas     int32  `json:"ready_replicas"`
	AvailableReplicas int32  `json:"available_replicas"`
	Age               int    `json:"age"`
}

type DeployYamlResponse struct {
	DeployYaml string `json:"deploy_yaml"`
}

// namespace
type GetNameSpaceInfo struct {
	Status string `json:"status"`
	Name   string `json:"name"`
	Age    int    `json:"age"`
}

// nodes
type GetNodesList struct {
	Status  string `json:"status"`
	Name    string `json:"name"`
	Version string `json:"version"`
	Address string `json:"address"`
	Arch    string `json:"arch"`
	Cpu     string `json:"cpu"`
	Memory  string `json:"memory"`
	Age     int    `json:"age"`
}

// svc
type GetSvcList struct {
	Name      string            `json:"name"`
	Namespace string            `json:"namespace"`
	Target    string            `json:"target"`
	Selector  map[string]string `json:"selector"`
	Type      string            `json:"type"`
	Age       int               `json:"age"`
}

type Response struct {
	StatusCode int    `json:"code"`
	StatusMsg  string `json:"msg,omitempty"`
}

type ResponseOfValidator struct {
	StatusCode int         `json:"code"`
	StatusMsg  interface{} `json:"msg,omitempty"`
}

func ValidatorResponse(err error) ResponseOfValidator {
	return ResponseOfValidator{
		-1,
		utils.Translate(err),
	}
}

var OK = Response{StatusCode: 1, StatusMsg: "success"}
